//
//  MusicPlayerTableViewCell.m
//  Movie
//
//  Created by cjy on 16/3/25.
//  Copyright © 2016年 HY. All rights reserved.
//

#import "MusicPlayerTableViewCell.h"
#import "ModelTrailer.h"
@implementation MusicPlayerTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.regdate = [[UILabel alloc]init];
        [self.contentView addSubview:self.regdate];
        
        self.des = [[UILabel alloc]init];
        [self.contentView addSubview:self.des];
        
        
    }

    return self;

}

- (void)layoutSubviews{

    [super layoutSubviews];
    
    self.regdate.frame = CGRectMake(20, 10, self.contentView.frame.size.width, 15);

//    self.des.frame = CGRectMake(10, 40, self.contentView.frame.size.width - 20, 200);

}

- (void)passModel:(ModelTrailer *)model{

    
    self.regdate.text = [NSString stringWithFormat:@"发布时间 : %@",model.regdate];
    self.regdate.font = [UIFont systemFontOfSize:12];
    self.regdate.textColor = [UIColor whiteColor];
    
    self.des.text = [NSString stringWithFormat:@"  简介: %@" ,model.descrip];
    self.des.textColor = [UIColor whiteColor];
    self.des.numberOfLines = 0;
    self.des.font = [UIFont systemFontOfSize:13];
    self.des.frame = CGRectMake(10, 30 , [UIScreen mainScreen].bounds.size.width-20, [[self class] heightForLabel:self.des.text]);
}


+ (CGFloat)heightForLabel:(NSString *)text{
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 40, 0) options: NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];
    
    return rect.size.height;
}


+ (CGFloat)heightForCell:(ModelTrailer *)model{
    
    CGFloat height =  [MusicPlayerTableViewCell heightForLabel:model.descrip];
    
    return height + 30;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
